#include <iostream>
#include <vector>
#include <cstdlib>
#include <ctime>
#include <math.h>
#include <algorithm>
using namespace std;

void temp(vector<int>& candidates,int target,vector<vector<int>>&result,vector<int>&a,int&size,int& j)
{
    if(target<=0)return;
    for(int i=j;i<size;i++){
        a.push_back(candidates[i]);
        temp(candidates,target-candidates[i],result,a,size,i);
        if(candidates[i] == target){
            result.push_back(a);
        }
        a.pop_back();
    }
}
vector<vector<int>> combinationSum(vector<int>& candidates, int target) {
    vector<vector<int>>result;
    vector<int>a;
    int size = candidates.size(),j=0;
    temp(candidates,target,result,a,size,j);
    return result;
}
int main(){
    vector<int>a={2,3,5};
    vector<vector<int>>result=combinationSum(a,8);
    for(auto temp:result){
        for(auto ite=temp.begin();ite!=temp.end();ite++){
            cout<<*ite<<",";
        }
        cout<<"\n";
    }
    return 0;
}